using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using WindowsPhoneGame1.GameScreens;

namespace WindowsPhoneGame1.GamePlayStates
{
    class StartState : GamePlayState
    {
        private Texture2D light;
        private Texture2D shine;

        private double time = 5;

        public StartState(Game1 game, Level level) : base(game, level)
        {
            pause = true;
        }
        
        public override void Initialize()
        {
            base.Initialize();
        }

        public override void LoadContent()
        {
            light = game.Content.Load<Texture2D>("images/ui/startscreen/Light");
            shine = game.Content.Load<Texture2D>("images/ui/startscreen/Shine");
        }

        public override void UnloadContent()
        {
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            time -= gameTime.ElapsedGameTime.TotalSeconds;

            if (time < 0)
                pause = false;

            if (time < -1)
                level.GamePlayState = new PlayState(game, level);
        }

        public override void Draw(GameTime gameTime)
        {

            float middle = game.GraphicsDevice.Viewport.Width / 2f;

            float height = 50;

            for (int i = 0; i < 4; i++)
            {
                game.SpriteBatch.Draw(light, new Vector2(middle - light.Width / 2f, height - light.Height / 2f), i == 3 ? Color.LightGreen : Color.Gold);
                height += light.Height;
            }

            height = 50;

            for(int i = 0; i < 4; i++)
            {
                if(time < 3 - i)
                game.SpriteBatch.Draw(shine, new Vector2(middle - shine.Width / 2f, height - shine.Height / 2f), i == 3 ? Color.LightGreen : Color.Gold);
                height += light.Height;
            }



            base.Draw(gameTime);


        }
    }
}
